.TH std::span::rend,std::span::crend 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::span::rend,std::span::crend \- std::span::rend,std::span::crend

.SH Synopsis
   constexpr reverse_iterator rend() const noexcept;        \fB(1)\fP \fI(since C++20)\fP
   constexpr const_reverse_iterator crend() const noexcept; \fB(2)\fP (since C++23)

   Returns a reverse iterator to the element following the last element of the reversed
   span. It corresponds to the element preceding the first element of the non-reversed
   span. This element acts as a placeholder, attempting to access it results in
   undefined behavior.

   range-rbegin-rend.svg

.SH Parameters

   \fI(none)\fP

.SH Return value

   Reverse iterator to the element following the last element.

.SH Complexity

   Constant.

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <span>
 #include <string_view>

 void ascending(const std::span<const std::string_view> data,
                const std::string_view term)
 {
     std::for_each(data.begin(), data.end(),
         [](const std::string_view x) { std::cout << x << ' '; });
     std::cout << term;
 }

 void descending(const std::span<const std::string_view> data,
                 const std::string_view term)
 {
     std::for_each(data.rbegin(), data.rend(),
         [](const std::string_view x) { std::cout << x << ' '; });
     std::cout << term;
 }

 int main()
 {
     constexpr std::string_view bars[]{"▁","▂","▃","▄","▅","▆","▇","█"};
     ascending(bars, " ");
     descending(bars, "\\n");
 }

.SH Output:

 ▁ ▂ ▃ ▄ ▅ ▆ ▇ █  █ ▇ ▆ ▅ ▄ ▃ ▂ ▁

.SH See also

   rbegin  returns a reverse iterator to the beginning
   crbegin \fI(public member function)\fP
   (C++23)
   rend    returns a reverse end iterator for a container or array
   crend   \fI(function template)\fP
   \fI(C++14)\fP
